package controllers;



import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.google.gson.Gson;
import models.Usuario;
import play.db.DB;
import oracle.sql.*;
import play.mvc.Controller;

public class Application extends Controller {

	static Gson gson = new Gson();	
	
    public static void index() {
    	if(Security.isAuthenticated()){
        	Usuario user = new Usuario();
    		user = (Usuario) gson.fromJson(session.get("usuario"), Usuario.class);
    		render(user);    		
    	}
    	else
    		login();
    }
    
	/**
	 * Login.
	 */
    public static void login () {
        render();

    }
    
	public static void testDb(){
		String test = null;
	
    	Connection conn = DB.getConnection();
    	
        try {
        	ResultSet rs = conn.createStatement().executeQuery("select * from SIGPC_EMPLEADO");
        	 while (rs.next()) {
                 test = rs.getString("EMP_EMAIL");
                 
        	 }
			render(test);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}